import { DataTypes } from 'sequelize'
import sequelize from '../utils/database.js'
import BaseModel from './BaseModel.js'

class Sms extends BaseModel {
  static associate(models) {
    // 定义一对一
    this.belongsTo(models.User, { foreignKey: 'user_id' })

    // 定义一对多
    // this.belongsTo(models.Sms, { foreignKey: 'user_id' })
  }
}

Sms.init({
  mobile: {
    type: DataTypes.STRING,
    allowNull: false
  },
  user_id: {
    type: DataTypes.STRING,
    allowNull: false,
    unique: true
  }
},
{
  sequelize,
  modelName: 'Sms',
  tableName: 'sms'
})

export default Sms